#include "stdafx.h"
#include "GamePlay.h"
#include "Skybox.h"

GamePlay::GamePlay()
:terrain(0)
{

}

GamePlay::~GamePlay()
{
	//SAFE_DEL(terrain);
}

int GamePlay::Init()
{
	int err = 0;
	int texCount = 5;
	char **aszFile = new char*[texCount];
	aszFile[0] = "../Resources/Textures/Blend.tga";
	aszFile[1] = "../Resources/Textures/Grass.tga";
	aszFile[2] = "../Resources/Textures/Dirt.tga";
	aszFile[3] = "../Resources/Textures/Rock.tga";
	aszFile[4] = "../Resources/Textures/Water.tga";
	terrain = new Terrain("../Resources/Textures/heightMap.raw", aszFile, texCount);
	terrain->Init();
	terrain->setShader(ResourceManager::GetInstance()->terrainShader);
	//terrain->SetScaleFactor(Vector3(20.0f, 4.0f, 20.0f));
	SAFE_DEL_ARRAY(aszFile);
	this->AddEntity(terrain);

	////Skybox
	//Skybox *skybox = new Skybox();
	//skybox->Init();
	//skybox->SetShader(ResourceManager::GetInstance()->m_skbShader);
	//skybox->SetScaleFactor(Vector3(5000.0f, 1000.0f, 5000.0f));
	//skybox->SetPositon(Vector3(0.0f, 400.0f, 0.0f));
	//this->AddEntity(skybox);

	return err;
}

void GamePlay::Key(ESContext *esContext, unsigned char key, bool bIsPressed)
{

}

void GamePlay::Mouse(ESContext* esContext, MouseData mouseData, bool bIsdown)
{

}

void GamePlay::Update(ESContext* esContext, float deltatime)
{
	terrain->update(deltatime);
}

void GamePlay::Draw(ESContext* esContext)
{
	//glEnable(GL_DEPTH_TEST);
	terrain->draw();
	//this->m_ListEntities[1]->draw();
	
	//State::Draw(esContext);
	glClear(GL_DEPTH_TEST);
}


int GamePlay::Release()
{
	return 0;
}
